package functions.mams_rest;

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.beans.AdminUserBean;

import coms.Constants;

import frame.HttpHelper;

public class User {
	private static Logger logger = LoggerFactory.getLogger(User.class);
	String result;
	AdminUserBean userBean;
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public AdminUserBean getUserBean() {
		return userBean;
	}
	public void setUserBean(AdminUserBean userBean) {
		this.userBean = userBean;
	}
	
	/**
	 * 审批通过
	 */
	public void admin() {
		logger.info(" admin------------------- start---------------------");
		String url = Constants.JOB_ADMIN_URL;
    	try {
			result = HttpHelper.post("", url);
			logger.info("admin--------"+ result);
			JSONObject object = new JSONObject(result);
			String occupation = "";
			try {
				occupation= (String) object.get("occupation");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String companyDesc = "";
			try {
				companyDesc = (String) object.get("companyDesc");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String departmentId = "";
			try {
				departmentId = (String) object.get("departmentId");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			
			String telephone = "";
			try{
				telephone= (String) object.get("telephone");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			
			
			String empNo = "";
			try{
				empNo = (String) object.get("empNo");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			
			String userName = "";
			try{
				userName = (String) object.get("userName");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String substitute = "";
			try{
				substitute = (String) object.get("substitute");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String userCode = "";
			try{
				userCode = (String) object.get("userCode");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String occupationCode = "";
			try{
				occupationCode = (String) object.get("occupationCode");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String company = "";
			try{
				company = (String) object.get("company");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String applyDate = "";
			try{
				applyDate = (String) object.get("applyDate");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String department = "";
			try{
				department = (String) object.get("department");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			String email = "";
			try{
				email = (String) object.get("email");
			}catch(Exception e) {
				//e.printStackTrace();
			}
			
			userBean = new AdminUserBean(occupation,companyDesc,departmentId,telephone,
					empNo,userName,substitute,userCode,
					occupationCode,company,applyDate,department,email,null,null,null,null);
		//	System.out.println(userBean.toString());
    	}catch(Exception e) {
    		e.printStackTrace();
    	}
    	logger.info("admin ------------------- end---------------------");
	  }

}
